import { GIcon, GModalForm } from 'geminis-react';
import { GFormSchema } from 'geminis-react/Form/FormSchema';

export const Terminate = (props: {
  processId: string[];
  onSuccess: () => void;
}) => {
  const form = {
    schema: {
      data: {
        url: '/api/workflow/processes/stop',
        methodSubmit: 'delete',
        format: 'form',
      },
      fields: {
        type: 'object',
        properties: {
          reason: {
            type: 'string',
            title: '原因',
            required: true,
            'x-decorator': 'FormItem',
            'x-component': 'Input.TextArea',
            'x-component-props': {
              placeholder: '请输入原因',
              rows: 5,
            },
          },
        },
      },
    },
    onSubmitting: (schema: GFormSchema, value: any) => {
      value.processIds = props.processId;
    },
    onSubmitted: props.onSuccess,
  };

  return (
    <GModalForm
      button={{
        text: '终止流程',
        button: { type:'link' },
      }}
      form={form}
    />
  );
};
